﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Senthil.Mobile.WhereAmI
{
    public partial class NewLocationGroupForm : Form
    {
        public NewLocationGroupForm()
        {
            InitializeComponent();
        }
        
        List<Location> locations = new List<Location>();

        internal bool IsSpecial
        {
            get { return specialLocationGroupCheckBox.Checked; }
        }

        internal IEnumerable<Location> Locations
        {
            set { locations = new List<Location>(value); }
        }

        internal Location[] SelectedLocations
        {
            get 
            { 
                return
                (from ListViewItem locationItem in locationsList.CheckedItems 
                select ((Location)locationItem.Tag)).ToArray();
            }     
        }

        internal string LocationGroupName
        {
            get { return locationGroupTextBox.Text; }
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void NewLocationGroupForm_Load(object sender, EventArgs e)
        {
            foreach (Location location in locations)
            {
                ListViewItem item = locationsList.Items.Add(location.Name);
                item.Tag = location;
            }
        }
    }
}
